
*******************************************************************************
* COUNTY LEVEL ANALYSIS
*******************************************************************************	

use pva_county_property, clear

* Property Assessment
* No controls
xtreg logpprealdorccd i.er#ib1989.year i.tech#ib1989.year i.er i.tech i.year /// 
 if year<=1998 & countyfip!=21063 & countyfip!=21151  & countyfip!=21161, fe cl(countyfip)
* Controls
xtreg logpprealdorccd i.er#ib1989.year i.tech#ib1989.year ///
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.cntyspecedquartile1987#c.postkeratr ib4.cntyflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<=1998 & countyfip!=21063 & countyfip!=21151  & countyfip!=21161, fe cl(countyfip)

* COD
* No controls
xtreg resid_COD i.er#ib1989.year i.tech#ib1989.year i.er i.tech i.year /// 
 if ((year>=1982 & year<=1989) | inlist(year, 1992, 1995, 1996, 1998)) /// 
 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)
* Controls
xtreg 	resid_COD i.er#ib1989.year i.tech#ib1989.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.cntyspecedquartile1987#c.postkeratr ib4.cntyflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if ((year>=1982 & year<=1989) | inlist(year, 1992, 1995, 1996, 1998)) /// 
 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)

* Sales-to-Assessment Ratios
* No Controls
xtreg resid_median i.er#ib1989.year i.tech#ib1989.year i.er i.tech i.year /// 
 if ((year>=1982 & year<=1989) | inlist(year, 1992, 1995, 1996, 1998)) /// 
 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)
* Controls
xtreg 	resid_median i.er#ib1989.year i.tech#ib1989.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.cntyspecedquartile1987#c.postkeratr ib4.cntyflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if ((year>=1982 & year<=1989) | inlist(year, 1992, 1995, 1996, 1998)) /// 
 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)

* Simple 2x2 DID for commercial and farm ratios
xtreg commerc_median i.er#ib1989.year i.tech#ib1989.year  ///
		i.er i.tech ///
		i.year if inlist(year, 1989, 1996) & commerc_COD!=., fe cl(countyfip)

xtreg commerc_COD i.er#ib1989.year i.tech#ib1989.year /// 
		i.er i.tech ///
		i.year if inlist(year, 1989, 1996) & commerc_COD!=., fe cl(countyfip)

xtreg farm_median i.er#ib1989.year i.tech#ib1989.year /// 
		i.er i.tech ///
		i.year if inlist(year, 1989, 1996) & farm_COD!=., fe cl(countyfip)
		
xtreg farm_COD i.er#ib1989.year i.tech#ib1989.year /// 
		i.er i.tech ///
		i.year if inlist(year, 1989, 1996) & farm_COD!=., fe cl(countyfip) 

* Longrun performance audit
foreach var of varlist res_cod_audit res_med_audit farm_cod_audit farm_med_audit {
	xtreg `var' i.er#ib1989.year i.tech#ib1989.year ///
	ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
	ib4.cntyspecedquartile1987#c.postkeratr ib4.cntyflequartile1987#c.postkeratr ///
	i.coal_cnty#i.year ///
	i.er i.tech i.year /// 
	if no_years==5 & countyfip!=21063 & countyfip!=21151  & countyfip!=21161, /// 
	fe cl(countyfip)
}


* Robustness Check: Home value
xtreg logrealppagghv i.er#ib1990.year i.tech#ib1990.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.cntyspecedquartile1987#c.postkeratr ib4.cntyflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year if countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)
 
/*
Robustness check using home price data in robust_check_hpi.do
*/

* Robustness Check: Net migration & FRPL
xtreg netmig i.er#ib1990.year i.tech#ib1990.year ///
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.cntyspecedquartile1987#c.postkeratr ib4.cntyflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<=1998 & countyfip!=21063 & countyfip!=21151  & countyfip!=21161, fe cl(countyfip)

test 1.er#1991.year 1.er#1992.year 1.er#1993.year 1.er#1994.year
test 1.tech#1991.year 1.tech#1992.year 1.tech#1993.year 1.tech#1994.year

xtreg cntyflepct i.er#ib1990.year i.tech#ib1990.year ///
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.cntyspecedquartile1987#c.postkeratr ib4.cntyflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<=1998 & countyfip!=21063 & countyfip!=21151  & countyfip!=21161, fe cl(countyfip)


*******************************************************************************
* DISTRICT LEVEL ANALYSIS
*******************************************************************************	

*------------------------------------------------------------------------------
* Full sample
*------------------------------------------------------------------------------
use pva_district_rev, clear

* Total local revenue
* No Controls
xtreg 	logrealpplocalrevsccd i.er#ib1990.year i.tech#ib1990.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)
* Controls
xtreg 	logrealpplocalrevsccd i.er#ib1990.year i.tech#ib1990.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.distspecedquartile1987#c.postkeratr ib4.distflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)

* LER
* No Controls
xtreg lerate i.er#ib1990.year i.tech#ib1990.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)
estimates store m_ler
* Controls
xtreg lerate i.er#ib1990.year i.tech#ib1990.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.distspecedquartile1987#c.postkeratr ib4.distflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161, fe cl(countyfip)
estimates store m_lerctrl

*------------------------------------------------------------------------------
* Heterogeneity by LER constraint subsets
*------------------------------------------------------------------------------

* Revenue
* Subset of constrained counties 
xtreg logrealpplocalrevsccd i.er#ib1990.year i.tech#ib1990.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.distspecedquartile1987#c.postkeratr ib4.distflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161 & ler1990_le30==1, fe cl(countyfip)
* Subset of unconstrained counties 
xtreg 	logrealpplocalrevsccd i.er#ib1990.year i.tech#ib1990.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.distspecedquartile1987#c.postkeratr ib4.distflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161 & ler1990_le30==0, fe cl(countyfip)

* LER
* Subset of constrained counties 
xtreg lerate i.er#ib1990.year i.tech#ib1990.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.distspecedquartile1987#c.postkeratr ib4.distflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161 & ler1990_le30==1, fe cl(countyfip)
* Subset of unconstrained counties 
xtreg lerate i.er#ib1990.year i.tech#ib1990.year /// 
 ib4.hv1980_quartile#c.postkeratr ib4.ler1990_quartile#c.postkeratr ///
 ib4.distspecedquartile1987#c.postkeratr ib4.distflequartile1987#c.postkeratr ///
 i.coal_cnty#i.year ///
 i.er i.tech i.year /// 
 if year<1999 & countyfip!=21063 & countyfip!=21151 & countyfip!=21161 & ler1990_le30==0, fe cl(countyfip)


